package com.platform.core.web.controller;

import com.platform.core.service.SysMsgManageBiz;
import com.platform.dto.SysMsgManageVo;
import com.platform.comm.web.results.DataJsonResult;
import com.platform.comm.web.results.JsonResult;
import com.platform.comm.web.results.PageListJsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


/**
 * Description: 消息管理-管理接口
 *
 * @author Coder
 */
@RestController
@RequestMapping(name = "消息管理管理", path = "/management/lcodeMsgManage")
public class SysMsgManageController {

    private final SysMsgManageBiz sysMsgManageBiz;

    @Autowired
    public SysMsgManageController(SysMsgManageBiz sysMsgManageBiz) {
        this.sysMsgManageBiz = sysMsgManageBiz;
    }

    /**
     * 新建消息
     */
    @PostMapping(name = "新建消息", path = "/addMsg")
    public JsonResult addMsg(@RequestBody SysMsgManageVo manageVo) {
        sysMsgManageBiz.addMsg(manageVo);
        return JsonResult.success();
    }


    /**
     * 分页查询
     */
    @PostMapping(name = "分页查询", path = "/search")
    public PageListJsonResult<SysMsgManageVo> search(@RequestBody Map<String, String> map) {
        Page<SysMsgManageVo> entities = sysMsgManageBiz.search(map, BaseController.getPageable(map));
        return new PageListJsonResult<>(entities);
    }

    /**
     * 删除
     */
    @PostMapping(name = "删除", path = "/delete")
    public JsonResult delete(@RequestBody Map<String, String> map) {
        sysMsgManageBiz.delete(map);
        return JsonResult.success();
    }

    /**
     * 详情
     */
    @PostMapping(name = "详情", path = "/detail")
    public DataJsonResult<SysMsgManageVo> detail(@RequestBody Map<String, String> map) {
        SysMsgManageVo msgManageVo = sysMsgManageBiz.detail(map);
        return DataJsonResult.succeed(msgManageVo);
    }
}
